const express = require("express");
const HairProject = require("../models/hair");
const router = new express.Router();
router.post("/hair", async(req, res) => {
    await HairProject.create(req.body);
    res.setHeader("Access-Control-Allow-Origin", "*");
    res.setHeader("Access-Control-Allow-Headers", "*");
    res.setHeader("Access-Control-Allow-Methods", "*");
    res.send("数据提交成功！！");
});
router.get("/hair", async(req, res) => {
    console.log(req.query);
    const result = await HairProject.find(req.query, {
        _id: 0,
        __v: 0
    });
    res.setHeader("Access-Control-Allow-Origin", "*");
    res.setHeader("Access-Control-Allow-Headers", "*");
    res.setHeader("Access-Control-Allow-Methods", "*");
    res.send(result);
});
module.exports = router;